package com.koala.aideddevsystemmodule.modules.conditionalOnMissingBean.config;

import com.koala.aideddevsystemmodule.modules.conditionalOnMissingBean.entity.ConditionalOnMissingBeanEntity;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ConditionalOnMissingBean： 当当前Spring容器中没有指定类时执行，有指定类时则不执行
 * 测试：
 *  解开 ConditionalOnMissingBeanEntity.java 的注释，
 *  运行AidedDevSystemModuleApplication.java，
 *  查看控制台输出
 * Create by koala on 2022-08-24
 */
@Configuration
public class BootConfiguration {

    @Bean
    @ConditionalOnMissingBean({ConditionalOnMissingBeanEntity.class})
    public ConditionalOnMissingBeanEntity defaultTokenManager() {
        return new ConditionalOnMissingBeanEntity();
    }

    @Bean
    @ConditionalOnMissingBean({ConditionalOnMissingBeanEntity.class})
    public ConditionalOnMissingBeanEntity defaultTokenManager2() {
        return new ConditionalOnMissingBeanEntity();
    }

    @Bean
    @ConditionalOnMissingBean({ConditionalOnMissingBeanEntity.class})
    public ConditionalOnMissingBeanEntity defaultTokenManager3() {
        return new ConditionalOnMissingBeanEntity();
    }

}